<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class RDoc::Markup::Parser - rdoc: Ruby Standard Library Documentation</title>


<script src="../../js/navigation.js" defer></script>
<script src="../../js/search.js" defer></script>
<script src="../../js/search_index.js" defer></script>
<script src="../../js/searcher.js" defer></script>
<script src="../../js/darkfish.js" defer></script>

<script src="../../js/jquery-3.2.0.min.js"></script>

<script src="../../js/vue.min.js"></script>
<script src="../../js/js.cookie.min.js"></script>

<link href="../../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../../css/rdoc.css" rel="stylesheet">
<link href="../../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../../";
  var index_rel_prefix = "../../";
  var darkModeCsseHref = "../../css/rdoc-dm.css"
  var defaultModeCssHref = "../../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../../table_of_contents.html#pages">Pages</a>
    <a href="../../table_of_contents.html#classes">Classes</a>
    <a href="../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link"><a href="../../Object.html">Object</a>
</div>

        
<div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
    <li><a class="include" href="../Text.html">RDoc::Text</a>
  </ul>
</div>

        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-c-parse">::parse</a>
    <li ><a href="#method-c-tokenize">::tokenize</a>
    <li ><a href="#method-i-build_heading">#build_heading</a>
    <li ><a href="#method-i-build_list">#build_list</a>
    <li ><a href="#method-i-build_paragraph">#build_paragraph</a>
    <li ><a href="#method-i-build_verbatim">#build_verbatim</a>
    <li ><a href="#method-i-get">#get</a>
    <li ><a href="#method-i-parse">#parse</a>
    <li ><a href="#method-i-peek_token">#peek_token</a>
    <li ><a href="#method-i-setup_scanner">#setup_scanner</a>
    <li ><a href="#method-i-skip">#skip</a>
    <li ><a href="#method-i-tokenize">#tokenize</a>
    <li ><a href="#method-i-unget">#unget</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-RDoc::Markup::Parser">
    <h1 id="class-RDoc::Markup::Parser" class="class">
      class RDoc::Markup::Parser
    </h1>

    <section class="description">
    
<p>A recursive-descent parser for <a href="../../RDoc.html"><code>RDoc</code></a> markup.</p>

<p>The parser tokenizes an input string then parses the tokens into a Document. Documents can be converted into output formats by writing a visitor like RDoc::Markup::ToHTML.</p>

<p>The parser only handles the block-level constructs Paragraph, List, ListItem, Heading, Verbatim, BlankLine, Rule and BlockQuote. Inline markup such as <code>+blah+</code> is handled separately by <a href="AttributeManager.html"><code>RDoc::Markup::AttributeManager</code></a>.</p>

<p>To see what markup the <a href="Parser.html"><code>Parser</code></a> implements read <a href="../../RDoc.html"><code>RDoc</code></a>.  To see how to use <a href="../../RDoc.html"><code>RDoc</code></a> markup to format text in your program read <a href="../Markup.html"><code>RDoc::Markup</code></a>.</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="LIST_TOKENS">LIST_TOKENS
          <dd><p>List token types</p>
        </dl>
        </section>

        <section class="attribute-method-details" class="method-section">
        <header>
        <h3>Attributes</h3>
        </header>

          <div id="attribute-i-debug" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">debug</span><span
                class="attribute-access-type">[RW]</span>
            </div>

            <div class="method-description">
              <p>Enables display of debugging information</p>
              </div>
            </div>
          <div id="attribute-i-tokens" class="method-detail">
            <div class="method-heading attribute-method-heading">
              <span class="method-name">tokens</span><span
                class="attribute-access-type">[R]</span>
            </div>

            <div class="method-description">
              <p>Token accessor</p>
              </div>
            </div>
            </section>


                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates a new <a href="Parser.html"><code>Parser</code></a>.  See also <a href="Parser.html#method-c-parse"><code>::parse</code></a></p>

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File rdoc/markup/parser.rb, line 79</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>
  <span class="ruby-ivar">@binary_input</span>   = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@current_token</span>  = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@debug</span>          = <span class="ruby-keyword">false</span>
  <span class="ruby-ivar">@s</span>              = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@tokens</span>         = []
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-parse" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">parse</span><span
                                class="method-args">(str)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Parses <code>str</code> into a Document.</p>

<p>Use RDoc::Markup#parse instead of this method.</p>

                              <div class="method-source-code" id="parse-source">
            <pre><span class="ruby-comment"># File rdoc/markup/parser.rb, line 60</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">parse</span> <span class="ruby-identifier">str</span>
  <span class="ruby-identifier">parser</span> = <span class="ruby-identifier">new</span>
  <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">tokenize</span> <span class="ruby-identifier">str</span>
  <span class="ruby-identifier">doc</span> = <span class="ruby-constant">RDoc</span><span class="ruby-operator">::</span><span class="ruby-constant">Markup</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">parse</span> <span class="ruby-identifier">doc</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-tokenize" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">tokenize</span><span
                                class="method-args">(str)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns a token stream for <code>str</code>, for testing</p>

                              <div class="method-source-code" id="tokenize-source">
            <pre><span class="ruby-comment"># File rdoc/markup/parser.rb, line 70</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">tokenize</span> <span class="ruby-identifier">str</span>
  <span class="ruby-identifier">parser</span> = <span class="ruby-identifier">new</span>
  <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">tokenize</span> <span class="ruby-identifier">str</span>
  <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">tokens</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-build_heading" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">build_heading</span><span
                                class="method-args">(level)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Builds a Heading of <code>level</code></p>

                              <div class="method-source-code" id="build_heading-source">
            <pre><span class="ruby-comment"># File rdoc/markup/parser.rb, line 90</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">build_heading</span> <span class="ruby-identifier">level</span>
  <span class="ruby-identifier">type</span>, <span class="ruby-identifier">text</span>, = <span class="ruby-identifier">get</span>

  <span class="ruby-identifier">text</span> = <span class="ruby-keyword">case</span> <span class="ruby-identifier">type</span>
         <span class="ruby-keyword">when</span> <span class="ruby-value">:TEXT</span> <span class="ruby-keyword">then</span>
           <span class="ruby-identifier">skip</span> <span class="ruby-value">:NEWLINE</span>
           <span class="ruby-identifier">text</span>
         <span class="ruby-keyword">else</span>
           <span class="ruby-identifier">unget</span>
           <span class="ruby-string">&#39;&#39;</span>
         <span class="ruby-keyword">end</span>

  <span class="ruby-constant">RDoc</span><span class="ruby-operator">::</span><span class="ruby-constant">Markup</span><span class="ruby-operator">::</span><span class="ruby-constant">Heading</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">level</span>, <span class="ruby-identifier">text</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-build_list" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">build_list</span><span
                                class="method-args">(margin)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Builds a List flush to <code>margin</code></p>

                              <div class="method-source-code" id="build_list-source">
            <pre><span class="ruby-comment"># File rdoc/markup/parser.rb, line 108</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">build_list</span> <span class="ruby-identifier">margin</span>
  <span class="ruby-identifier">p</span> <span class="ruby-value">:list_start</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">margin</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@debug</span>

  <span class="ruby-identifier">list</span> = <span class="ruby-constant">RDoc</span><span class="ruby-operator">::</span><span class="ruby-constant">Markup</span><span class="ruby-operator">::</span><span class="ruby-constant">List</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-identifier">label</span> = <span class="ruby-keyword">nil</span>

  <span class="ruby-keyword">until</span> <span class="ruby-ivar">@tokens</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">type</span>, <span class="ruby-identifier">data</span>, <span class="ruby-identifier">column</span>, = <span class="ruby-identifier">get</span>

    <span class="ruby-keyword">case</span> <span class="ruby-identifier">type</span>
    <span class="ruby-keyword">when</span> <span class="ruby-operator">*</span><span class="ruby-constant">LIST_TOKENS</span> <span class="ruby-keyword">then</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">column</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">margin</span> <span class="ruby-operator">||</span> (<span class="ruby-identifier">list</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">list</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">type</span>) <span class="ruby-keyword">then</span>
        <span class="ruby-identifier">unget</span>
        <span class="ruby-keyword">break</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">list</span>.<span class="ruby-identifier">type</span> = <span class="ruby-identifier">type</span>
      <span class="ruby-identifier">peek_type</span>, <span class="ruby-identifier">_</span>, <span class="ruby-identifier">column</span>, = <span class="ruby-identifier">peek_token</span>

      <span class="ruby-keyword">case</span> <span class="ruby-identifier">type</span>
      <span class="ruby-keyword">when</span> <span class="ruby-value">:NOTE</span>, <span class="ruby-value">:LABEL</span> <span class="ruby-keyword">then</span>
        <span class="ruby-identifier">label</span> = [] <span class="ruby-keyword">unless</span> <span class="ruby-identifier">label</span>

        <span class="ruby-keyword">if</span> <span class="ruby-identifier">peek_type</span> <span class="ruby-operator">==</span> <span class="ruby-value">:NEWLINE</span> <span class="ruby-keyword">then</span>
          <span class="ruby-comment"># description not on the same line as LABEL/NOTE</span>
          <span class="ruby-comment"># skip the trailing newline &amp; any blank lines below</span>
          <span class="ruby-keyword">while</span> <span class="ruby-identifier">peek_type</span> <span class="ruby-operator">==</span> <span class="ruby-value">:NEWLINE</span>
            <span class="ruby-identifier">get</span>
            <span class="ruby-identifier">peek_type</span>, <span class="ruby-identifier">_</span>, <span class="ruby-identifier">column</span>, = <span class="ruby-identifier">peek_token</span>
          <span class="ruby-keyword">end</span>

          <span class="ruby-comment"># we may be:</span>
          <span class="ruby-comment">#   - at end of stream</span>
          <span class="ruby-comment">#   - at a column &lt; margin:</span>
          <span class="ruby-comment">#         [text]</span>
          <span class="ruby-comment">#       blah blah blah</span>
          <span class="ruby-comment">#   - at the same column, but with a different type of list item</span>
          <span class="ruby-comment">#       [text]</span>
          <span class="ruby-comment">#       * blah blah</span>
          <span class="ruby-comment">#   - at the same column, with the same type of list item</span>
          <span class="ruby-comment">#       [one]</span>
          <span class="ruby-comment">#       [two]</span>
          <span class="ruby-comment"># In all cases, we have an empty description.</span>
          <span class="ruby-comment"># In the last case only, we continue.</span>
          <span class="ruby-keyword">if</span> <span class="ruby-identifier">peek_type</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">column</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">margin</span> <span class="ruby-keyword">then</span>
            <span class="ruby-identifier">empty</span> = <span class="ruby-keyword">true</span>
          <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">column</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">margin</span> <span class="ruby-keyword">then</span>
            <span class="ruby-keyword">case</span> <span class="ruby-identifier">peek_type</span>
            <span class="ruby-keyword">when</span> <span class="ruby-identifier">type</span>
              <span class="ruby-identifier">empty</span> = <span class="ruby-value">:continue</span>
            <span class="ruby-keyword">when</span> <span class="ruby-operator">*</span><span class="ruby-constant">LIST_TOKENS</span>
              <span class="ruby-identifier">empty</span> = <span class="ruby-keyword">true</span>
            <span class="ruby-keyword">else</span>
              <span class="ruby-identifier">empty</span> = <span class="ruby-keyword">false</span>
            <span class="ruby-keyword">end</span>
          <span class="ruby-keyword">else</span>
            <span class="ruby-identifier">empty</span> = <span class="ruby-keyword">false</span>
          <span class="ruby-keyword">end</span>

          <span class="ruby-keyword">if</span> <span class="ruby-identifier">empty</span> <span class="ruby-keyword">then</span>
            <span class="ruby-identifier">label</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">data</span>
            <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">empty</span> <span class="ruby-operator">==</span> <span class="ruby-value">:continue</span>
            <span class="ruby-keyword">break</span>
          <span class="ruby-keyword">end</span>
        <span class="ruby-keyword">end</span>
      <span class="ruby-keyword">else</span>
        <span class="ruby-identifier">data</span> = <span class="ruby-keyword">nil</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-keyword">if</span> <span class="ruby-identifier">label</span> <span class="ruby-keyword">then</span>
        <span class="ruby-identifier">data</span> = <span class="ruby-identifier">label</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">data</span>
        <span class="ruby-identifier">label</span> = <span class="ruby-keyword">nil</span>
      <span class="ruby-keyword">end</span>

      <span class="ruby-identifier">list_item</span> = <span class="ruby-constant">RDoc</span><span class="ruby-operator">::</span><span class="ruby-constant">Markup</span><span class="ruby-operator">::</span><span class="ruby-constant">ListItem</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">data</span>
      <span class="ruby-identifier">parse</span> <span class="ruby-identifier">list_item</span>, <span class="ruby-identifier">column</span>
      <span class="ruby-identifier">list</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">list_item</span>

    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">unget</span>
      <span class="ruby-keyword">break</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">p</span> <span class="ruby-value">:list_end</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">margin</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@debug</span>

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">list</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">then</span>
    <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">label</span>
    <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">unless</span> [<span class="ruby-value">:LABEL</span>, <span class="ruby-value">:NOTE</span>].<span class="ruby-identifier">include?</span> <span class="ruby-identifier">list</span>.<span class="ruby-identifier">type</span>

    <span class="ruby-identifier">list_item</span> = <span class="ruby-constant">RDoc</span><span class="ruby-operator">::</span><span class="ruby-constant">Markup</span><span class="ruby-operator">::</span><span class="ruby-constant">ListItem</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">label</span>, <span class="ruby-constant">RDoc</span><span class="ruby-operator">::</span><span class="ruby-constant">Markup</span><span class="ruby-operator">::</span><span class="ruby-constant">BlankLine</span>.<span class="ruby-identifier">new</span>
    <span class="ruby-identifier">list</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">list_item</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">list</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-build_paragraph" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">build_paragraph</span><span
                                class="method-args">(margin)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Builds a Paragraph that is flush to <code>margin</code></p>

                              <div class="method-source-code" id="build_paragraph-source">
            <pre><span class="ruby-comment"># File rdoc/markup/parser.rb, line 208</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">build_paragraph</span> <span class="ruby-identifier">margin</span>
  <span class="ruby-identifier">p</span> <span class="ruby-value">:paragraph_start</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">margin</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@debug</span>

  <span class="ruby-identifier">paragraph</span> = <span class="ruby-constant">RDoc</span><span class="ruby-operator">::</span><span class="ruby-constant">Markup</span><span class="ruby-operator">::</span><span class="ruby-constant">Paragraph</span>.<span class="ruby-identifier">new</span>

  <span class="ruby-keyword">until</span> <span class="ruby-ivar">@tokens</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">type</span>, <span class="ruby-identifier">data</span>, <span class="ruby-identifier">column</span>, = <span class="ruby-identifier">get</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value">:TEXT</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">column</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">margin</span> <span class="ruby-keyword">then</span>
      <span class="ruby-identifier">paragraph</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">data</span>

      <span class="ruby-keyword">break</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">peek_token</span>.<span class="ruby-identifier">first</span> <span class="ruby-operator">==</span> <span class="ruby-value">:BREAK</span>

      <span class="ruby-identifier">data</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39; &#39;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">skip</span> <span class="ruby-value">:NEWLINE</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">unget</span>
      <span class="ruby-keyword">break</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">paragraph</span>.<span class="ruby-identifier">parts</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">sub!</span>(<span class="ruby-regexp">/ \z/</span>, <span class="ruby-string">&#39;&#39;</span>) <span class="ruby-comment"># cleanup</span>

  <span class="ruby-identifier">p</span> <span class="ruby-value">:paragraph_end</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">margin</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@debug</span>

  <span class="ruby-identifier">paragraph</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-build_verbatim" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">build_verbatim</span><span
                                class="method-args">(margin)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Builds a Verbatim that is indented from <code>margin</code>.</p>

<p>The verbatim block is shifted left (the least indented lines start in column 0).  Each part of the verbatim is one line of text, always terminated by a newline.  Blank lines always consist of a single newline character, and there is never a single newline at the end of the verbatim.</p>

                              <div class="method-source-code" id="build_verbatim-source">
            <pre><span class="ruby-comment"># File rdoc/markup/parser.rb, line 243</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">build_verbatim</span> <span class="ruby-identifier">margin</span>
  <span class="ruby-identifier">p</span> <span class="ruby-value">:verbatim_begin</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">margin</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@debug</span>
  <span class="ruby-identifier">verbatim</span> = <span class="ruby-constant">RDoc</span><span class="ruby-operator">::</span><span class="ruby-constant">Markup</span><span class="ruby-operator">::</span><span class="ruby-constant">Verbatim</span>.<span class="ruby-identifier">new</span>

  <span class="ruby-identifier">min_indent</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">generate_leading_spaces</span> = <span class="ruby-keyword">true</span>
  <span class="ruby-identifier">line</span> = <span class="ruby-string">&#39;&#39;</span>.<span class="ruby-identifier">dup</span>

  <span class="ruby-keyword">until</span> <span class="ruby-ivar">@tokens</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">type</span>, <span class="ruby-identifier">data</span>, <span class="ruby-identifier">column</span>, = <span class="ruby-identifier">get</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value">:NEWLINE</span> <span class="ruby-keyword">then</span>
      <span class="ruby-identifier">line</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">data</span>
      <span class="ruby-identifier">verbatim</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">line</span>
      <span class="ruby-identifier">line</span> = <span class="ruby-string">&#39;&#39;</span>.<span class="ruby-identifier">dup</span>
      <span class="ruby-identifier">generate_leading_spaces</span> = <span class="ruby-keyword">true</span>
      <span class="ruby-keyword">next</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">column</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">margin</span>
      <span class="ruby-identifier">unget</span>
      <span class="ruby-keyword">break</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">generate_leading_spaces</span> <span class="ruby-keyword">then</span>
      <span class="ruby-identifier">indent</span> = <span class="ruby-identifier">column</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">margin</span>
      <span class="ruby-identifier">line</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39; &#39;</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">indent</span>
      <span class="ruby-identifier">min_indent</span> = <span class="ruby-identifier">indent</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">min_indent</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">indent</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">min_indent</span>
      <span class="ruby-identifier">generate_leading_spaces</span> = <span class="ruby-keyword">false</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-keyword">case</span> <span class="ruby-identifier">type</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:HEADER</span> <span class="ruby-keyword">then</span>
      <span class="ruby-identifier">line</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39;=&#39;</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">data</span>
      <span class="ruby-identifier">_</span>, <span class="ruby-identifier">_</span>, <span class="ruby-identifier">peek_column</span>, = <span class="ruby-identifier">peek_token</span>
      <span class="ruby-identifier">peek_column</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">column</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">data</span>
      <span class="ruby-identifier">indent</span> = <span class="ruby-identifier">peek_column</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">column</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">data</span>
      <span class="ruby-identifier">line</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39; &#39;</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">indent</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:RULE</span> <span class="ruby-keyword">then</span>
      <span class="ruby-identifier">width</span> = <span class="ruby-value">2</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">data</span>
      <span class="ruby-identifier">line</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39;-&#39;</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">width</span>
      <span class="ruby-identifier">_</span>, <span class="ruby-identifier">_</span>, <span class="ruby-identifier">peek_column</span>, = <span class="ruby-identifier">peek_token</span>
      <span class="ruby-identifier">peek_column</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">column</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">width</span>
      <span class="ruby-identifier">indent</span> = <span class="ruby-identifier">peek_column</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">column</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">width</span>
      <span class="ruby-identifier">line</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39; &#39;</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">indent</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:BREAK</span>, <span class="ruby-value">:TEXT</span> <span class="ruby-keyword">then</span>
      <span class="ruby-identifier">line</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">data</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:BLOCKQUOTE</span> <span class="ruby-keyword">then</span>
      <span class="ruby-identifier">line</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39;&gt;&gt;&gt;&#39;</span>
      <span class="ruby-identifier">peek_type</span>, <span class="ruby-identifier">_</span>, <span class="ruby-identifier">peek_column</span> = <span class="ruby-identifier">peek_token</span>
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">peek_type</span> <span class="ruby-operator">!=</span> <span class="ruby-value">:NEWLINE</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">peek_column</span>
        <span class="ruby-identifier">line</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39; &#39;</span> <span class="ruby-operator">*</span> (<span class="ruby-identifier">peek_column</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">column</span> <span class="ruby-operator">-</span> <span class="ruby-value">3</span>)
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">else</span> <span class="ruby-comment"># *LIST_TOKENS</span>
      <span class="ruby-identifier">list_marker</span> = <span class="ruby-keyword">case</span> <span class="ruby-identifier">type</span>
                    <span class="ruby-keyword">when</span> <span class="ruby-value">:BULLET</span> <span class="ruby-keyword">then</span> <span class="ruby-identifier">data</span>
                    <span class="ruby-keyword">when</span> <span class="ruby-value">:LABEL</span>  <span class="ruby-keyword">then</span> <span class="ruby-node">&quot;[#{data}]&quot;</span>
                    <span class="ruby-keyword">when</span> <span class="ruby-value">:NOTE</span>   <span class="ruby-keyword">then</span> <span class="ruby-node">&quot;#{data}::&quot;</span>
                    <span class="ruby-keyword">else</span> <span class="ruby-comment"># :LALPHA, :NUMBER, :UALPHA</span>
                      <span class="ruby-node">&quot;#{data}.&quot;</span>
                    <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">line</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">list_marker</span>
      <span class="ruby-identifier">peek_type</span>, <span class="ruby-identifier">_</span>, <span class="ruby-identifier">peek_column</span> = <span class="ruby-identifier">peek_token</span>
      <span class="ruby-keyword">unless</span> <span class="ruby-identifier">peek_type</span> <span class="ruby-operator">==</span> <span class="ruby-value">:NEWLINE</span> <span class="ruby-keyword">then</span>
        <span class="ruby-identifier">peek_column</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">column</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">list_marker</span>.<span class="ruby-identifier">length</span>
        <span class="ruby-identifier">indent</span> = <span class="ruby-identifier">peek_column</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">column</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">list_marker</span>.<span class="ruby-identifier">length</span>
        <span class="ruby-identifier">line</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&#39; &#39;</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">indent</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">verbatim</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-string">&quot;\n&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">empty?</span>
  <span class="ruby-identifier">verbatim</span>.<span class="ruby-identifier">parts</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-identifier">p</span>.<span class="ruby-identifier">slice!</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">min_indent</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">p</span> <span class="ruby-operator">==</span> <span class="ruby-string">&quot;\n&quot;</span> } <span class="ruby-keyword">if</span> <span class="ruby-identifier">min_indent</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
  <span class="ruby-identifier">verbatim</span>.<span class="ruby-identifier">normalize</span>

  <span class="ruby-identifier">p</span> <span class="ruby-value">:verbatim_end</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">margin</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@debug</span>

  <span class="ruby-identifier">verbatim</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-get" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">get</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Pulls the next token from the stream.</p>

                              <div class="method-source-code" id="get-source">
            <pre><span class="ruby-comment"># File rdoc/markup/parser.rb, line 327</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">get</span>
  <span class="ruby-ivar">@current_token</span> = <span class="ruby-ivar">@tokens</span>.<span class="ruby-identifier">shift</span>
  <span class="ruby-identifier">p</span> <span class="ruby-value">:get</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-ivar">@current_token</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@debug</span>
  <span class="ruby-ivar">@current_token</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-parse" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">parse</span><span
                                class="method-args">(parent, indent = 0)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Parses the tokens into an array of RDoc::Markup::XXX objects, and appends them to the passed <code>parent</code> RDoc::Markup::YYY object.</p>

<p>Exits at the end of the token stream, or when it encounters a token in a column less than <code>indent</code> (unless it is a NEWLINE).</p>

<p>Returns <code>parent</code>.</p>

                              <div class="method-source-code" id="parse-source">
            <pre><span class="ruby-comment"># File rdoc/markup/parser.rb, line 342</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">parse</span> <span class="ruby-identifier">parent</span>, <span class="ruby-identifier">indent</span> = <span class="ruby-value">0</span>
  <span class="ruby-identifier">p</span> <span class="ruby-value">:parse_start</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">indent</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@debug</span>

  <span class="ruby-keyword">until</span> <span class="ruby-ivar">@tokens</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">type</span>, <span class="ruby-identifier">data</span>, <span class="ruby-identifier">column</span>, = <span class="ruby-identifier">get</span>

    <span class="ruby-keyword">case</span> <span class="ruby-identifier">type</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:BREAK</span> <span class="ruby-keyword">then</span>
      <span class="ruby-identifier">parent</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">RDoc</span><span class="ruby-operator">::</span><span class="ruby-constant">Markup</span><span class="ruby-operator">::</span><span class="ruby-constant">BlankLine</span>.<span class="ruby-identifier">new</span>
      <span class="ruby-identifier">skip</span> <span class="ruby-value">:NEWLINE</span>, <span class="ruby-keyword">false</span>
      <span class="ruby-keyword">next</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:NEWLINE</span> <span class="ruby-keyword">then</span>
      <span class="ruby-comment"># trailing newlines are skipped below, so this is a blank line</span>
      <span class="ruby-identifier">parent</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">RDoc</span><span class="ruby-operator">::</span><span class="ruby-constant">Markup</span><span class="ruby-operator">::</span><span class="ruby-constant">BlankLine</span>.<span class="ruby-identifier">new</span>
      <span class="ruby-identifier">skip</span> <span class="ruby-value">:NEWLINE</span>, <span class="ruby-keyword">false</span>
      <span class="ruby-keyword">next</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-comment"># indentation change: break or verbatim</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">column</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">indent</span> <span class="ruby-keyword">then</span>
      <span class="ruby-identifier">unget</span>
      <span class="ruby-keyword">break</span>
    <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">column</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">indent</span> <span class="ruby-keyword">then</span>
      <span class="ruby-identifier">unget</span>
      <span class="ruby-identifier">parent</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">build_verbatim</span>(<span class="ruby-identifier">indent</span>)
      <span class="ruby-keyword">next</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-comment"># indentation is the same</span>
    <span class="ruby-keyword">case</span> <span class="ruby-identifier">type</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:HEADER</span> <span class="ruby-keyword">then</span>
      <span class="ruby-identifier">parent</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">build_heading</span>(<span class="ruby-identifier">data</span>)
    <span class="ruby-keyword">when</span> <span class="ruby-value">:RULE</span> <span class="ruby-keyword">then</span>
      <span class="ruby-identifier">parent</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">RDoc</span><span class="ruby-operator">::</span><span class="ruby-constant">Markup</span><span class="ruby-operator">::</span><span class="ruby-constant">Rule</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">data</span>)
      <span class="ruby-identifier">skip</span> <span class="ruby-value">:NEWLINE</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:TEXT</span> <span class="ruby-keyword">then</span>
      <span class="ruby-identifier">unget</span>
      <span class="ruby-identifier">parse_text</span> <span class="ruby-identifier">parent</span>, <span class="ruby-identifier">indent</span>
    <span class="ruby-keyword">when</span> <span class="ruby-value">:BLOCKQUOTE</span> <span class="ruby-keyword">then</span>
      <span class="ruby-keyword">nil</span> <span class="ruby-keyword">while</span> (<span class="ruby-identifier">type</span>, = <span class="ruby-identifier">get</span>; <span class="ruby-identifier">type</span>) <span class="ruby-keyword">and</span> <span class="ruby-identifier">type</span> <span class="ruby-operator">!=</span> <span class="ruby-value">:NEWLINE</span>
      <span class="ruby-identifier">_</span>, <span class="ruby-identifier">_</span>, <span class="ruby-identifier">column</span>, = <span class="ruby-identifier">peek_token</span>
      <span class="ruby-identifier">bq</span> = <span class="ruby-constant">RDoc</span><span class="ruby-operator">::</span><span class="ruby-constant">Markup</span><span class="ruby-operator">::</span><span class="ruby-constant">BlockQuote</span>.<span class="ruby-identifier">new</span>
      <span class="ruby-identifier">p</span> <span class="ruby-value">:blockquote_start</span> <span class="ruby-operator">=&gt;</span> [<span class="ruby-identifier">data</span>, <span class="ruby-identifier">column</span>] <span class="ruby-keyword">if</span> <span class="ruby-ivar">@debug</span>
      <span class="ruby-identifier">parse</span> <span class="ruby-identifier">bq</span>, <span class="ruby-identifier">column</span>
      <span class="ruby-identifier">p</span> <span class="ruby-value">:blockquote_end</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">indent</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@debug</span>
      <span class="ruby-identifier">parent</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">bq</span>
    <span class="ruby-keyword">when</span> <span class="ruby-operator">*</span><span class="ruby-constant">LIST_TOKENS</span> <span class="ruby-keyword">then</span>
      <span class="ruby-identifier">unget</span>
      <span class="ruby-identifier">parent</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">build_list</span>(<span class="ruby-identifier">indent</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">type</span>, <span class="ruby-identifier">data</span>, <span class="ruby-identifier">column</span>, <span class="ruby-identifier">line</span> = <span class="ruby-ivar">@current_token</span>
      <span class="ruby-identifier">raise</span> <span class="ruby-constant">ParseError</span>, <span class="ruby-node">&quot;Unhandled token #{type} (#{data.inspect}) at #{line}:#{column}&quot;</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">p</span> <span class="ruby-value">:parse_end</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">indent</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@debug</span>

  <span class="ruby-identifier">parent</span>

<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-peek_token" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">peek_token</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the next token on the stream without modifying the stream</p>

                              <div class="method-source-code" id="peek_token-source">
            <pre><span class="ruby-comment"># File rdoc/markup/parser.rb, line 413</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">peek_token</span>
  <span class="ruby-identifier">token</span> = <span class="ruby-ivar">@tokens</span>.<span class="ruby-identifier">first</span> <span class="ruby-operator">||</span> []
  <span class="ruby-identifier">p</span> <span class="ruby-value">:peek</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">token</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@debug</span>
  <span class="ruby-identifier">token</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-setup_scanner" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">setup_scanner</span><span
                                class="method-args">(input)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Creates the StringScanner</p>

                              <div class="method-source-code" id="setup_scanner-source">
            <pre><span class="ruby-comment"># File rdoc/markup/parser.rb, line 464</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">setup_scanner</span> <span class="ruby-identifier">input</span>
  <span class="ruby-ivar">@s</span> = <span class="ruby-constant">MyStringScanner</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">input</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-skip" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">skip</span><span
                                class="method-args">(token_type, error = true)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Skips the next token if its type is <code>token_type</code>.</p>

<p>Optionally raises an error if the next token is not of the expected type.</p>

                              <div class="method-source-code" id="skip-source">
            <pre><span class="ruby-comment"># File rdoc/markup/parser.rb, line 473</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">skip</span> <span class="ruby-identifier">token_type</span>, <span class="ruby-identifier">error</span> = <span class="ruby-keyword">true</span>
  <span class="ruby-identifier">type</span>, = <span class="ruby-identifier">get</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">type</span> <span class="ruby-comment"># end of stream</span>
  <span class="ruby-keyword">return</span> <span class="ruby-ivar">@current_token</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">token_type</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">type</span>
  <span class="ruby-identifier">unget</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">ParseError</span>, <span class="ruby-node">&quot;expected #{token_type} got #{@current_token.inspect}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">error</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-tokenize" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">tokenize</span><span
                                class="method-args">(input)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Turns text <code>input</code> into a stream of tokens</p>

                              <div class="method-source-code" id="tokenize-source">
            <pre><span class="ruby-comment"># File rdoc/markup/parser.rb, line 484</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">tokenize</span> <span class="ruby-identifier">input</span>
  <span class="ruby-identifier">setup_scanner</span> <span class="ruby-identifier">input</span>

  <span class="ruby-keyword">until</span> <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">eos?</span> <span class="ruby-keyword">do</span>
    <span class="ruby-identifier">pos</span> = <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">pos</span>

    <span class="ruby-comment"># leading spaces will be reflected by the column of the next token</span>
    <span class="ruby-comment"># the only thing we loose are trailing spaces at the end of the file</span>
    <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp">/ +/</span>)

    <span class="ruby-comment"># note: after BULLET, LABEL, etc.,</span>
    <span class="ruby-comment"># indent will be the column of the next non-newline token</span>

    <span class="ruby-ivar">@tokens</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword">case</span>
               <span class="ruby-comment"># [CR]LF =&gt; :NEWLINE</span>
               <span class="ruby-keyword">when</span> <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp">/\r?\n/</span>) <span class="ruby-keyword">then</span>
                 <span class="ruby-identifier">token</span> = [<span class="ruby-value">:NEWLINE</span>, <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">matched</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">pos</span>]
                 <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">newline!</span>
                 <span class="ruby-identifier">token</span>
               <span class="ruby-comment"># === text =&gt; :HEADER then :TEXT</span>
               <span class="ruby-keyword">when</span> <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp">/(=+)(\s*)/</span>) <span class="ruby-keyword">then</span>
                 <span class="ruby-identifier">level</span> = <span class="ruby-ivar">@s</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">length</span>
                 <span class="ruby-identifier">header</span> = [<span class="ruby-value">:HEADER</span>, <span class="ruby-identifier">level</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">pos</span>]

                 <span class="ruby-keyword">if</span> <span class="ruby-ivar">@s</span>[<span class="ruby-value">2</span>] <span class="ruby-operator">=~</span> <span class="ruby-regexp">/^\r?\n/</span> <span class="ruby-keyword">then</span>
                   <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">unscan</span>(<span class="ruby-ivar">@s</span>[<span class="ruby-value">2</span>])
                   <span class="ruby-identifier">header</span>
                 <span class="ruby-keyword">else</span>
                   <span class="ruby-identifier">pos</span> = <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">pos</span>
                   <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp">/.*/</span>)
                   <span class="ruby-ivar">@tokens</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">header</span>
                   [<span class="ruby-value">:TEXT</span>, <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">matched</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp">/\r$/</span>, <span class="ruby-string">&#39;&#39;</span>), <span class="ruby-operator">*</span><span class="ruby-identifier">pos</span>]
                 <span class="ruby-keyword">end</span>
               <span class="ruby-comment"># --- (at least 3) and nothing else on the line =&gt; :RULE</span>
               <span class="ruby-keyword">when</span> <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp">/(-{3,}) *\r?$/</span>) <span class="ruby-keyword">then</span>
                 [<span class="ruby-value">:RULE</span>, <span class="ruby-ivar">@s</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">length</span> <span class="ruby-operator">-</span> <span class="ruby-value">2</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">pos</span>]
               <span class="ruby-comment"># * or - followed by white space and text =&gt; :BULLET</span>
               <span class="ruby-keyword">when</span> <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp">/([*-]) +(\S)/</span>) <span class="ruby-keyword">then</span>
                 <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">unscan</span>(<span class="ruby-ivar">@s</span>[<span class="ruby-value">2</span>])
                 [<span class="ruby-value">:BULLET</span>, <span class="ruby-ivar">@s</span>[<span class="ruby-value">1</span>], <span class="ruby-operator">*</span><span class="ruby-identifier">pos</span>]
               <span class="ruby-comment"># A. text, a. text, 12. text =&gt; :UALPHA, :LALPHA, :NUMBER</span>
               <span class="ruby-keyword">when</span> <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp">/([a-z]|\d+)\. +(\S)/i</span>) <span class="ruby-keyword">then</span>
                 <span class="ruby-comment"># FIXME if tab(s), the column will be wrong</span>
                 <span class="ruby-comment"># either support tabs everywhere by first expanding them to</span>
                 <span class="ruby-comment"># spaces, or assume that they will have been replaced</span>
                 <span class="ruby-comment"># before (and provide a check for that at least in debug</span>
                 <span class="ruby-comment"># mode)</span>
                 <span class="ruby-identifier">list_label</span> = <span class="ruby-ivar">@s</span>[<span class="ruby-value">1</span>]
                 <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">unscan</span>(<span class="ruby-ivar">@s</span>[<span class="ruby-value">2</span>])
                 <span class="ruby-identifier">list_type</span> =
                   <span class="ruby-keyword">case</span> <span class="ruby-identifier">list_label</span>
                   <span class="ruby-keyword">when</span> <span class="ruby-regexp">/[a-z]/</span> <span class="ruby-keyword">then</span> <span class="ruby-value">:LALPHA</span>
                   <span class="ruby-keyword">when</span> <span class="ruby-regexp">/[A-Z]/</span> <span class="ruby-keyword">then</span> <span class="ruby-value">:UALPHA</span>
                   <span class="ruby-keyword">when</span> <span class="ruby-regexp">/\d/</span>    <span class="ruby-keyword">then</span> <span class="ruby-value">:NUMBER</span>
                   <span class="ruby-keyword">else</span>
                     <span class="ruby-identifier">raise</span> <span class="ruby-constant">ParseError</span>, <span class="ruby-node">&quot;BUG token #{list_label}&quot;</span>
                   <span class="ruby-keyword">end</span>
                 [<span class="ruby-identifier">list_type</span>, <span class="ruby-identifier">list_label</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">pos</span>]
               <span class="ruby-comment"># [text] followed by spaces or end of line =&gt; :LABEL</span>
               <span class="ruby-keyword">when</span> <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp">/\[(.*?)\]( +|\r?$)/</span>) <span class="ruby-keyword">then</span>
                 [<span class="ruby-value">:LABEL</span>, <span class="ruby-ivar">@s</span>[<span class="ruby-value">1</span>], <span class="ruby-operator">*</span><span class="ruby-identifier">pos</span>]
               <span class="ruby-comment"># text:: followed by spaces or end of line =&gt; :NOTE</span>
               <span class="ruby-keyword">when</span> <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp">/(.*?)::( +|\r?$)/</span>) <span class="ruby-keyword">then</span>
                 [<span class="ruby-value">:NOTE</span>, <span class="ruby-ivar">@s</span>[<span class="ruby-value">1</span>], <span class="ruby-operator">*</span><span class="ruby-identifier">pos</span>]
               <span class="ruby-comment"># &gt;&gt;&gt; followed by end of line =&gt; :BLOCKQUOTE</span>
               <span class="ruby-keyword">when</span> <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp">/&gt;&gt;&gt; *(\w+)?$/</span>) <span class="ruby-keyword">then</span>
                 <span class="ruby-keyword">if</span> <span class="ruby-identifier">word</span> = <span class="ruby-ivar">@s</span>[<span class="ruby-value">1</span>]
                   <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">unscan</span>(<span class="ruby-identifier">word</span>)
                 <span class="ruby-keyword">end</span>
                 [<span class="ruby-value">:BLOCKQUOTE</span>, <span class="ruby-identifier">word</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">pos</span>]
               <span class="ruby-comment"># anything else: :TEXT</span>
               <span class="ruby-keyword">else</span>
                 <span class="ruby-ivar">@s</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp">/(.*?)(  )?\r?$/</span>)
                 <span class="ruby-identifier">token</span> = [<span class="ruby-value">:TEXT</span>, <span class="ruby-ivar">@s</span>[<span class="ruby-value">1</span>], <span class="ruby-operator">*</span><span class="ruby-identifier">pos</span>]

                 <span class="ruby-keyword">if</span> <span class="ruby-ivar">@s</span>[<span class="ruby-value">2</span>] <span class="ruby-keyword">then</span>
                   <span class="ruby-ivar">@tokens</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">token</span>
                   [<span class="ruby-value">:BREAK</span>, <span class="ruby-ivar">@s</span>[<span class="ruby-value">2</span>], <span class="ruby-identifier">pos</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">+</span> <span class="ruby-ivar">@s</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">length</span>, <span class="ruby-identifier">pos</span>[<span class="ruby-value">1</span>]]
                 <span class="ruby-keyword">else</span>
                   <span class="ruby-identifier">token</span>
                 <span class="ruby-keyword">end</span>
               <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">self</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-unget" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">unget</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns the current token to the token stream</p>

                              <div class="method-source-code" id="unget-source">
            <pre><span class="ruby-comment"># File rdoc/markup/parser.rb, line 574</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">unget</span>
  <span class="ruby-identifier">token</span> = <span class="ruby-ivar">@current_token</span>
  <span class="ruby-identifier">p</span> <span class="ruby-value">:unget</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">token</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@debug</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">Error</span>, <span class="ruby-string">&#39;too many #ungets&#39;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">token</span> <span class="ruby-operator">==</span> <span class="ruby-ivar">@tokens</span>.<span class="ruby-identifier">first</span>
  <span class="ruby-ivar">@tokens</span>.<span class="ruby-identifier">unshift</span> <span class="ruby-identifier">token</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">token</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

